// 请求接口
import { getList,addStoreManage,isCheck,storeManageChart} from '@/api/storeManage'

import Qs from 'qs'

const state = {}

const mutations = {}

const actions = {

  // 获取 仓库管理 列表信息
  async getList({commit},serchForm) {
    let res = await getList(serchForm);
    return res
  },
  // 添加 仓库管理 信息
  async addStoreManage({},storeManageForm) {
    const res = await addStoreManage(storeManageForm);
    return res
  },
  
  // 修改 仓库管理 check
  async isCheck({},checkInfo) {
    let params = Qs.stringify(checkInfo)
    const res = await isCheck(checkInfo.id,params);
    return res
  },
  // 
  async storeManageChart({},searchForm) {

    let {supId,time,isIn} = searchForm
        console.log(supId);
        console.log(time);
    let res ;
    let params
       if(time.length > 1) {
        params = {
              supplier:{id: supId},
              createTime:time[0],
              updateTime:time[1],
              isIn:isIn,
              isCheck:1
            }
           res = await storeManageChart(params);
       }else{
        params = {supplier:{id: supId},isIn:isIn,isCheck:1}
           res = await storeManageChart(params);
       }
       console.log(params)
       console.log(res);
    return res
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

